<%@ page language="Java" import="java.util.*,descriptor.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%
	StudentListDescriptor studentList = (StudentListDescriptor)request.getAttribute("Students");
	FeedbackListDescriptor feedbackDes = (FeedbackListDescriptor)request.getAttribute("FeedbackDes");
	String studentID = (String)request.getAttribute("studentID");
	String viewFeedbacks = (String)request.getAttribute("viewFeedbacks");
	String error1 = (String)request.getAttribute("error1");
	String error2 = (String)request.getAttribute("error2");
%>

<html>
	<jsp:include page="CareerHeader.jsp" >
		<jsp:param name="pageTitle" value="Work Placement Management System - Career Officer" />
	</jsp:include>
	<body OnLoad="showmenu(document.getElementById('smenu6'));">
		<jsp:include page="CareerPageHeader.jsp"></jsp:include>
		<div id="container">
			<jsp:include page="CareerMenu.jsp" ></jsp:include>
			<div id="content">
				<h3 class="posttitle">Career Officer - Students' Feedbacks</h3>
				<div class="entry">
					<%
							int sizeList = studentList.getStudentList().size();
							if(sizeList > 0)
							{
					%>
					<p>Select a student in the list to display its feedbacks</p>
					<br>
					<form name="frmstudentList" method="post" style="margin-left: auto; margin-right: auto;">
						<input type="hidden" name="action" value="viewFeedbacks1"> 
						<select OnChange="document.frmstudentList.submit();" name="stdtID">  
							<option value="">Select a student: </option>  
					<%
								
								for(int i=0; i<sizeList; i++)
								{
									String selected = "";
									String studentlogin = studentList.getStudentList().get(i).getLogin();
									String studentSName = studentList.getStudentList().get(i).getSurName();
									String studentFName = studentList.getStudentList().get(i).getFirstName();
									int id = studentList.getStudentList().get(i).getId();
									if(studentID !=null && Integer.parseInt(studentID) == id)
									{
										selected = "selected";
									}
					%>
							<option value="<%= id %>" <%= selected %>><%= studentlogin %> - <%= studentSName %>, <%= studentFName %></option>
					<%			
								}
					%>
						</select>
					</form>
					<br>
					<hr>
					<%
							}
							else
							{ 
								if(error1 != null)
					%>
									<p><%= error1 %></p>
					<%	
							} 
							
							if(viewFeedbacks != null)
							{
								if(viewFeedbacks.equals("1") && feedbackDes != null)
								{
					%>
						<br>
						<table rules="all">
							<thead>
								<tr>
									<th>Author</th><th>Name</th><th>Feedback</th>
							</thead>
							<tbody>
					<%
									int size = feedbackDes.getFeedbackDescriptors().size();
									for(int i=0 ; i<size ; i++)
									{
					%>
										<tr>	
											<td><%= feedbackDes.getFeedbackDescriptors().get(i).getAuthorName() %></td>
											<td><%= feedbackDes.getFeedbackDescriptors().get(i).getName() %></td>
											<td><%= feedbackDes.getFeedbackDescriptors().get(i).getInfos() %></td>
										</tr>
					<%
									}
					%>
							</tbody>
						</table>
					<% 			
								}
							}
							else
							{
								if(error2 != null)
								{				
					%>
									<p style="color:red; font-size: 10px;"><%= error2 %></p>
					<%
								}
							}	
					%>
				</div>
			</div>
			<jsp:include page="CareerPageFooter.jsp"></jsp:include>
		</div>
	</body>
</html>